<%@Page Language="VB" debug="true"%>
<%@Import Namespace="System.Drawing" %>
<html>
<head>

<script language="JScript">
<!--
function ShowHTMLContent() {
  var strURL = 'http://<% = Request.ServerVariables("SERVER_NAME") %><% = Request.Path %>?<% = Request.QueryString %>';
  var strDisplay = new String;
  var objHTTP = new ActiveXObject("microsoft.XMLHTTP")
  objHTTP.open('GET', strURL, false);
  objHTTP.send();
  var strReply = objHTTP.responseText;
  var intStart = strReply.indexOf('<!' + '--start-->') + 12;
  var intEnd = strReply.indexOf('<!' + '--end-->');
  if ((intStart > 0) && (intEnd > intStart))
    var strDisplay = strReply.substring(intStart, intEnd);
  document.all['outHTML'].innerText = strDisplay + ' ';
}
function SetCheck(strCheckboxName) {
  document.all[strCheckboxName].checked = true;
}
//-->
</script>

<!-- #include file="style.inc" -->
</head>
<body bgcolor="#ffffff" onload="ShowHTMLContent()">
<!--------------------------------------------------------------------------->
<span class="heading">HtmlSelect Control</span> &nbsp; &nbsp; &nbsp;

<!--start-->
<select id="MyControl" runat="server" />
<!--end-->

<p />
<div id="outError" runat="server" />
<font face="Courier New" size="2"><div style="background-color:gainsboro; padding-left:10px" id="outHTML">Fetching HTML content...</div></font>

<form runat="server" method="get">
<table border="0">
<tr>
<td nowrap="nowrap"></td><td align="right" nowrap="nowrap">DataSource =</td><td nowrap="nowrap">{HashTable}</td>
<td nowrap="nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp;</td>
<td nowrap="nowrap"><input type="checkbox" id="chkDataTextField" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">DataTextField =</td><td nowrap="nowrap"><select id="selDataTextField" size="1" runat="server" onchange="SetCheck('chkDataTextField')"><option>Key</option><option>Value</option></select></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkDataValueField" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">DataValueField =</td><td nowrap="nowrap"><select id="selDataValueField" size="1" runat="server" onchange="SetCheck('chkDataValueField')"><option>Key</option><option>Value</option></select></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkDisabled" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Disabled =</td><td nowrap="nowrap"><select id="selDisabled" size="1" runat="server" onchange="SetCheck('chkDisabled')"><option>True</option><option>False</option></select></td><td nowrap="nowrap"></td>
</tr><tr>
<td nowrap="nowrap"></td><td align="right" nowrap="nowrap">ID =</td><td nowrap="nowrap"><% = MyControl.ID %></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkMultiple" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Multiple =</td><td nowrap="nowrap"><select id="selMultiple" size="1" runat="server" onchange="SetCheck('chkMultiple')"><option>True</option><option>False</option></select></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkSelectedIndex" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">SelectedIndex =</td><td nowrap="nowrap"><select id="selSelectedIndex" size="1" runat="server" onchange="SetCheck('chkSelectedIndex')">
<option>-1</option><option>0</option><option>1</option><option>2</option><option>3</option><option>4</option></select></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkSize" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Size =</td><td nowrap="nowrap"><input type="text" size="2" id="txtSize" runat="server" onkeypress="SetCheck('chkSize')" /></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkValue" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Value =</td><td nowrap="nowrap"><select size="1" id="selValue" runat="server" onkeypress="SetCheck('chkValue')" /></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkVisible" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Visible =</td><td nowrap="nowrap"><select id="selVisible" size="1" runat="server" onchange="SetCheck('chkVisible')"><option>True</option><option>False</option></select></td>
</tr><tr>
<td></td><td></td><td></td><td></td>
<td nowrap="nowrap"><input type="button" Value="Reset" onclick="javascript:location.href='http://<% = Request.ServerVariables("SERVER_NAME") %><% = Request.Path %>'"></td><td nowrap="nowrap"></td><td nowrap="nowrap"><input type="submit" Value="Update" runat="server" /></td></tr>
</table>
</form>

<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
outError.innerHTML = ""
Try
   Dim tabValues As New HashTable(5)
   tabValues.Add("Microsoft", 49.56)
   tabValues.Add("Sun", 28.33)
   tabValues.Add("IBM", 55)
   tabValues.Add("Compaq", 20.74)
   tabValues.Add("Oracle", 41.1)
   MyControl.DataSource = tabValues
   If IsPostBack() Then
      If chkDataTextField.Checked Then 
	MyControl.DataTextField = selDataTextField.Value
      end if
      If chkDataValueField.Checked Then 
	MyControl.DataValueField = selDataValueField.Value
      end if
      MyControl.DataBind()
      If chkDisabled.Checked Then 
	MyControl.Disabled = selDisabled.Value
      end if
      If chkMultiple.Checked Then 
	MyControl.Multiple = selMultiple.Value
      end if
      If chkSelectedIndex.Checked Then 
	MyControl.SelectedIndex = selSelectedIndex.Value
      end if
      If chkSize.Checked Then 
	MyControl.Size = txtSize.Value
      end if
      If chkValue.Checked Then 
	MyControl.Value = selValue.Value
      end if
      If chkVisible.Checked Then 
	MyControl.Visible = selVisible.Value
      end if
   Else
      MyControl.DataValueField = "Value"
      MyControl.DataTextField = "Key"
      MyControl.DataBind()
   End If
   selDataTextField.Value = MyControl.DataTextField
   selDataValueField.Value = MyControl.DataValueField
   selDisabled.Value = MyControl.Disabled
   selMultiple.Value = MyControl.Multiple
   selSelectedIndex.Value = MyControl.SelectedIndex
   txtSize.Value = MyControl.Size
   selValue.Value = MyControl.Value
   selVisible.Value = MyControl.Visible
   selValue.DataSource = tabValues
   selValue.DataTextField = MyControl.DataValueField
   selValue.DataBind()
   selValue.Value = MyControl.Value
Catch objError As Exception
   outError.innerHTML = "<b>* Error</b>: " & objError.Message & "<p />"
End Try
End Sub
</script>

<!--------------------------------------------------------------------------->
<!-- #include file="foot.inc" -->
</body>
</html>
